<?php
	/*****************************************************************
		GP Clinic - a web based Medical directory system
		Copyright (C) 2014 Kaizensynergy - Gemba360

		Author: Bless Bauson
		Key: bHkTy89wZ0DHyUiim0041rTxyBbP671aQwg327UtjfcrO
	*****************************************************************/
	
	$health_fund_id = 0;

	//for form submit
	if($_SERVER['REQUEST_METHOD'] == "POST"){
		if(isset($_POST['id']) && !empty($_POST['id'])){
			$table_def 	= array(
							'update' => $_POST,
							'filter' => 'id = '.$_POST['id']
						  );
			$fund 		= new HealthFund($table_def);
			$fund->SQL_Update();
			$message = 2;
		}else{
			$_POST['date_created'] = date("Y-m-d h:i:s");
			$table_def 	= array('add' => $_POST);
			$fund 		= new HealthFund($table_def);
			$fund->SQL_Insert();
			$message = 1;
		}
	}

	//for edit form - fetch data
	if($_SERVER['REQUEST_METHOD'] == "GET"){
		$message = 0;

		if(count($_GET)){
			foreach($_GET as $key => $val){
				$newkey = str_replace("amp;","",$key);
				$_GET[$newkey] = $val;
			}
		}
		
		if(isset($_GET['row']) && !empty($_GET['row'])){
			$health_fund_id = $_GET['row'];

			$params = array( 'filter' => 'id = '.$health_fund_id);
			$fund 	= new HealthFund($params);
			$row 	= $fund->SQL_Select();
		}
	}
?>